console.log(1);

//回调函数
getUser(1,function(user){
    getRepositories(user.gitHubUserName,(repos)=>{
        console.log('repos',repos);
    })
});
console.log('结束');

function getUser(id,callback){
    setTimeout(()=>{
        console.log('正在链接');
        callback({id:id,gitHubUserName:'hewei'})
    },2000)
}

function getRepositories(username){
    return new Promise((resolve,reject)=>{
        setTimeout(()=>{
            console.log('正在调用GitHub API');
            resolve(['name1','name2']);
        },2000)
    });
}
